<?php

namespace App\Admin\Http\Requests;

class PermissionRequest extends Request
{
    /**
     * 用户请求认证
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * 设置请求验证规则
     *
     * @return array
     */
    public function rules()
    {
        $id = $this->route('roles') ?? 'NULL';

        return [
            'name' => 'required|max:50',
            'slug' => 'required|max:50|unique:permissions,slug,'.$id,
            'description' => 'max:100',
        ];
    }

    /**
     * 翻译验证属性
     *
     * @return array
     */
    public function attributes()
    {
        return [
            'name' => '名称',
            'slug' => '编码',
            'description' => '描述',
        ];
    }
}
